package com.wish.util;

import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

public class Upload {
    public static String upload(MultipartFile file, String path) throws IOException {
        String fname = UUID.randomUUID().toString();
        String filename = file.getOriginalFilename();
        String lname = filename.substring(filename.lastIndexOf("."));
        File file1 = new File(path+fname+lname);
        file.transferTo(file1);
        return fname+lname;
    }
}
